package org.mspring.mlog.service;

import org.mspring.mlog.dao.LinkDao;
import org.mspring.mlog.entity.Link;
import org.mspring.nbee.orm.dao.sql.builder.part.condition.SqlCondition;
import org.mspring.nbee.orm.dao.sql.pager.PageResult;
import org.mspring.nbee.orm.dao.sql.pager.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Gao Youbo
 * @since 2015-01-24 13:11:48
 */
@Service
public class LinkService {

    private static final Logger log = LoggerFactory.getLogger(LinkService.class);

    private LinkDao linkDao;

    public Link findById(long id) {
        return linkDao.findById(id);
    }

    public PageResult<Link> list(List<SqlCondition> conditions, Pager pager) {
        return linkDao.listPage(conditions, pager);
    }

    public List<Link> listAll() {
        return linkDao.listAll();
    }

    @Transactional
    public boolean insert(Link link) {
        return linkDao.insert(link);
    }

    @Transactional
    public boolean update(Link link) {
        return linkDao.update(link);
    }

    @Transactional
    public boolean deleteById(long id) {
        return linkDao.deleteById(id);
    }

    @Autowired
    public void setLinkDao(LinkDao linkDao) {
        this.linkDao = linkDao;
    }

}